import Vue from 'vue'
import Router from 'vue-router'
//import home from '@/components/view/public/home'
import homegu from '@/components/view/public/home_gu'
import login from '@/components/view/public/login'
import print_card from '@/components/view/student/print_card' //打印准考证

import stu_change from '@/components/view/student/stu_change' // 异动申请
import stu_change_fill from '@/components/view/student/stu_change_fill' // 异动申请

import stu_exam from '@/components/view/student/stu_exam' //考试安排
import stu_exam_start from '@/components/view/student/stu_exam_start' //开始考试

import stu_grade from '@/components/view/student/stu_grade'  //学生成绩
import tech_plan from '@/components/view/student/tech_plan'  //教学计划

import thesis from '@/components/view/student/thesis' //毕业论文
import thesis_title from '@/components/view/student/thesis_title' //论文题目

import welcome from '@/components/view/student/welcome'  //欢迎页
import stu_course_evaluate from '@/components/view/student/stu_course_evaluate'//学生课程评价

import stu_index from '@/components/view/student/stu_index'  //学生主页
import stu_info from '@/components/view/student/stu_info'  //学生信息
import course_page from '@/components/view/student/course_page'  //课程界面
import part_info  from '@/components/view/student/part_info'    //章节信息
import video from '@/components/view/student/video'     //视频点播
import resource_upload  from '@/components/view/student/resource_upload'     //资源上传
import resource_download  from '@/components/view/student/resource_download'     //资源下载
import teach_notice  from '@/components/view/student/teach_notice'     //教学公告
import section_exam  from '@/components/view/student/section_exam'     //章节测验
import section_exam_question  from '@/components/view/student/section_exam_question'     //测验题目
import teacher_info  from '@/components/view/student/teacher_info'     //教师信息
import study_course  from '@/components/view/student/study_course'     //教师信息



Vue.use(Router)

let router = new Router({
  routes: [
    {
      path: '/',
      name:'登陆页',
      component:login
    },
    {
      path: '/login',
      name:'登陆页',
      component:login
    },
    {
      path: '/homegu',
      name: '主页',
      redirect:'/welcome',
      component:homegu,
      leaf: true, //只有一个节点
      iconCls: 'el-icon-menu', //图标样式class

    },
    {
        path: '/welcome',
        component:homegu,
        name:'主页',
        leaf:true,
        iconCls:'el-icon-menu',
        children: [
          {path: '/welcome', component:welcome,name:'welcome'}
        ]
    },
    {
      path: '/stu_index',
      component:homegu,
      name:'学生主页',
      // leaf:false,
      menuShow: true,
      iconCls:'el-icon-menu',
      children: [
        {
          path: '/stu_index', component: stu_index, name:'学生主页',
        },
        {
          path: '/course_page',component: course_page, name:'课程界面',menuShow:true
        },
        {
          path: '/study_course',component: study_course, name:'学习课程',menuShow:false,
        },
        {
          path: '/resource_download',component: resource_download, name:'资源下载',menuShow:false,
        },
        {
          path: '/part_info',component: part_info, name:'小节信息',menuShow:false,
        },
        {
          path: '/video',component: video, name:'点播视频',menuShow:false,
        },
        {path:'/sectionList',component:section_exam,name:'章节测试'},
        {path:'/sectionTestPaperList',component:section_exam_question,name:'测验题目'},
        {path:'/courseEvaluate',component:stu_course_evaluate,name:'课程评价',menuShow:false},
        {path:'/teach_notice',component:teach_notice,name:'教学公告'},
        {path:'/teacher_info',component:teacher_info,name:'教师信息'},

      ]
    },
    {
      path:'/print_card',
      component:homegu,
      name:'主页',
      leaf:true,
      menuShow:true,
      iconCls:'el-icon-menu',
      children:[
        {
          path:'/print_card',component:print_card,name:'准考证'
        }
      ]
    },
    {
      path: '/stu_exam',
      component:homegu,
      name:'主页',
      leaf:true ,//只有一个节点
      menuShow:true,
      iconCls:'el-icon-document',
      children:[
        {path:'/stu_exam', component: stu_exam, name:'考试安排'}
      ]
    },
    {
      path: '/tech_plan',
      component:homegu,
      name: '主页',
      leaf:true,
      menuShow:true,
      iconCls:'el-icon-edit-outline',
      children:[
        {  path: '/tech_plan', component:tech_plan,name:'教学计划'}
    ]
  },
  {
    path: '/stu_grade',
    component:homegu,
    name: '主页',
    leaf:true,
    menuShow:true,
    iconCls:'el-icon-menu',
    children:[
      {  path: '/stu_grade', component:stu_grade,name:'学生成绩'}
    ]
   },
   {
     path: '/stu_info',
     component:homegu,
     name: '主页',
     leaf:true,
     menuShow:true,
     iconCls:'el-icon-view',
     children:[
       {  path: '/stu_info', component:stu_info,name:'学籍信息'}
     ]
    },
    {
      path: '/stu_exam_start',
      component:homegu,
      name: '主页',
      leaf:true,
      menuShow:false,
      iconCls:'el-icon-menu',
      children:[
        {  path: '/stu_exam_start', component:stu_exam_start,name:'开始考试'}
      ]
     },
     {
     path: '/thesis',
     component:homegu,
     name:'毕业论文',
     menuShow: true,
     iconCls:'el-icon-menu',
     children: [
       {path: '/thesis', component: thesis, name:'毕业论文列表',menuShow:true},
       {path: '/thesisLayout', component: thesis_title, name:'论文规范列表',menuShow:true}
     ]
   },
   //mei
   {
     path: '/transactionList',
     component:homegu,
     name:'学生异动',
     //leaf:true,
     menuShow: true,
     iconCls:'el-icon-menu',
     children: [
       {path: '/transactionList', component: stu_change, name:'异动申请',menuShow:true},
       {path: '/stu_change_fill', component: stu_change_fill, name:'申请填写',menuShow:true}
     ]
   }
  ]
})
router.beforeEach((to, from, next) => {
  let stu = JSON.parse(window.localStorage.getItem('user'));
       if(to.path == '/login' && stu != null){
            if (stu.rememberMe == true) {
              next({ path: '/home' });
           }else{
               window.localStorage.removeItem("user");
               next({ path: '/login' });
           }
       }
       if (stu == null && to.path != '/login') {
           next({ path: '/login' })
       } else {
           next()
       }

})

export default router;
